import request from '@/utils/request'

/**
 * 商品分类树状结构
 */
export function goodsTree() {
    return request.get(`shop/goods/category/tree`)
}
/**
 * 商品列表
 */
export function goodsList(params : Record<string, any>) {
    return request.get(`shop/goods/pages`, params)
}
/**
 * 获取商品详情
 */
export function goodsDetail(params : Record<string, any>) {
    return request.get(`shop/goods/detail`, params)
}
/**
 * 商品收藏-添加
 */
export function goodsCollect(id : number) {
    return request.post(`shop/goods/collect/`+id)
}
/**
 * 购物车-添加
 */
export function shopCart(data : any) {
    return request.post(`shop/cart`, data)
}
/**
 * 购物车-列表
 */
export function shopcartList() {
    return request.get(`shop/cart`)
}
/**
 * 购物车-删除
 */
export function deleteCart(data : any) {
    return request.put(`shop/cart/delete`, data)
}
/**
 * 获取商品分类列表
 */
export function categoryList(params : Record<string, any>) {
    return request.get(`shop/goods/category/list`, params)
}
/**
 * 订单-计算(创建订单第1步)
 */
export function calculateCreate(params : Record<string, any>) {
    return request.get(`shop/order_create/calculate`, params)
}
/**
 * 订单-创建(创建订单第2步-完成订单的创建)
 */
export function orderCreate(data : Record<string, any>) {
    return request.post(`shop/order_create/create`, data)
}

/**
 * 获取支付信息
 */
export function getPayInfo(tradeType : string, tradeId : number) {
    return request.get(`pay/info/${tradeType}/${tradeId}`, {}, { showErrorMessage: true })
}
/**
 * 去支付(第2步)

 */
export function goPayy(data : Record<string, any>) {
    return request.post(`pay`,data)
}